import request from '@/utils/request'

const api = {
  // 打卡相关接口
  createBookCheckInRecord: 'app-api/bookCheckInRecord/createBookCheckInRecord',
  getBookCheckInRecordById: 'app-api/bookCheckInRecord/getBookCheckInRecordById',
}

/**
 * 打卡
 * @param {Object} data 打卡数据
 * @param {number} data.booksCount 阅读书籍数量
 * @param {string} data.readingNotes 阅读心得
 * @returns {Promise} 响应数据
 * 响应结构：
 * {
 *   code: number,
 *   data: {},
 *   msg: string
 * }
 */
export const createBookCheckInRecord = (data) => {
  return request.post(api.createBookCheckInRecord, data)
}

/**
 * 查询打卡详情
 * @returns {Promise} 响应数据
 * 响应结构：
 * {
 *   code: number,
 *   data: {
 *     createTime: any,
 *     updateTime: any,
 *     creator: any,
 *     updater: any,
 *     deleted: any,
 *     id: any,
 *     userId: any,
 *     bookIds: any,
 *     readingNotes: any,
 *     createName: any,
 *     checkInDays: any,                // 打卡天数
 *     totalNumberOfReadings: any,      // 总阅读数量
 *     todayReadingTotal: number,       // 今日阅读数量
 *     thisWeekReadingTotal: number,    // 本周阅读数量
 *     thisMonthReadingTotal: number    // 本月阅读数量
 *   },
 *   msg: string
 * }
 */
export const getBookCheckInRecordById = () => {
  return request.get(api.getBookCheckInRecordById)
}
